import { Toast  } from "vant";
import cTitle from "components/title";

export default {
  //name: 'login',
  data() {
    return {
        teamYeji: 0,//总团队业绩
        zhiyingYeji: 0,//总直营业绩
        partnerYeji: 0,//总伙伴业绩
        date: '',//日期
        minDate: new Date(2020, 0, 1),
        maxDate: new Date(2085, 10, 1),
        currentDate: new Date(),
        pickerShow: false,
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log(localStorage.getItem("uid"),'uid')
    if(!localStorage.getItem("uid")){
        this.$router.push(this.fun.getUrl("member"));
        return
    }
    this.getData();
  },
  computed: {
   
  },
  methods: {
    partner(){
      this.$router.push(this.fun.getUrl("yunPartnerList"));
    },
    openPicker(){
        this.pickerShow = true;
    },
    pickerCancel(){
      this.pickerShow = false;
  },
    // formatter(type, val) {
    //     if (type === 'year') {
    //       return `${val}年`;
    //     } else if (type === 'month') {
    //       return `${val}月`;
    //     }
    //     return val;
    //   },
    getData(){
        $http.get("ZhengChengYc.shuju_list", {
            uid: localStorage.getItem("uid"),
            time: this.date
          }, "加载中").then((res) => {
            if (res.result == 1) {
              console.log(res,'shuju_list')
              this.teamYeji = res.data.all_yeji;
              this.zhiyingYeji = res.data.zhitui_yeji;
              this.partnerYeji = res.data.jiantui_yeji;
            }
          });
    },
    team(type){
      if(type == 1){
        this.$router.push(this.fun.getUrl("yunTeamPerformance",{id: type}));
      }
      
      
    },
    pickerConfirm(e){
        console.log(e,'确定')
        const dateString = e;

        // 将字符串转换为Date对象
        const date = new Date(dateString);
        
        // 提取年、‌月、‌日
        const year = date.getFullYear();
        const month = date.getMonth() + 1 < 10 ? '0'+ (date.getMonth() + 1): date.getMonth() + 1; // 月份是从0开始的，‌所以需要+1
        const day = date.getDate();
        
        // 拼接成年月日格式
        const formattedDate = `${year}-${month}`;
        console.log(formattedDate,'formattedDate')
        this.date = formattedDate;
        this.pickerShow = false;
        this.getData();
    }
  }
};
